
using AppKit;

namespace Introspection {

	[TestFixture]
	public class MacApiTypoTest : ApiTypoTest {
		NSSpellChecker? checker;

		public override void TypoTest ()
		{
			AssertMatchingOSVersionAndSdkVersion ();
			checker = new NSSpellChecker ();

			base.TypoTest ();
		}

		public override string GetTypo (string txt)
		{
			var checkRange = new NSRange (0, txt.Length);
			nint wordCount;
			var typoRange = checker!.CheckSpelling (txt, 0, "en_US", false, 0, out wordCount);
			if (typoRange.Length == 0)
				return String.Empty;
			return txt.Substring ((int) typoRange.Location, (int) typoRange.Length);
		}
	}
}
